<#macro tagTypes typeIds=''>
<style>
#tagTypes{line-height:25px;}
#tagTypes span{margin-right:8px;padding:3px;border:1px solid #aaa;}
</style>
<dl class="nowrap tagTypes">
	<dt>标签分类:</dt>
	<dd>
		<div id="tagTypes"></div>
		<input name="type[].id" type="hidden"/>
		<input name="type[].name" type="text" size="30" postField="name" suggestfields="id,name" lookupgroup="type[]" suggestUrl="common/tagTypeSuggest.html"/>
		<a class="button" href="javascript:;" onclick="addTagType($('input[name=\'type[].id\']',navTab.getCurrentPanel()).val(),$('input[name=\'type[].name\']',navTab.getCurrentPanel()).val());return false;">增加</a>
		<span class="info">点击某个标签分类可以将其删除</span>
	</dd>
</dl>
<script>
function addTagType($id,$name){
	if($name){
		$name=$name.trim();
	}
	if($('#tagTypes span',navTab.getCurrentPanel()).size()>10){
		alertMsg.error('标签分类不能超过10个');
	}else{
		if($id&&$name){
			$('#tagTypes',navTab.getCurrentPanel()).append("<span><a href=\"javascript:;\" onclick=\"$(this).parent().remove();reIndexTagType();return false;\">"+$name+"</a><input type=\"hidden\" name=\"tagTypes[].id\" value=\""+$id+"\"/></span>");
		}else if($name){
			$('#tagTypes',navTab.getCurrentPanel()).append("<span><a href=\"javascript:;\" onclick=\"$(this).parent().remove();reIndexTagType();return false;\">"+$name+"</a><input type=\"hidden\" name=\"tagTypes[].name\" value=\""+$name+"\"/></span>");
		}
		reIndexTagType();
	}
	$('input[name=\'type[].id\']',navTab.getCurrentPanel()).val('');
	$('input[name=\'type[].name\']',navTab.getCurrentPanel()).val('');
}
function reIndexTagType(){
	$('#tagTypes span',navTab.getCurrentPanel()).each(function(tagIndex){
		$('input[name$=\\.id]',this).attr('name','tagTypes['+tagIndex+'].id');
		$('input[name$=\\.name]',this).attr('name','tagTypes['+tagIndex+'].name');
	});
}
	<@_tagType ids=typeIds>
		<#list map?keys as k>
		addTagType('${k}','${map[k].name?js_string}');
		</#list>
	</@_tagType>
</script>
</#macro>